export interface LanguageState {
  language: 'zh' | 'en',
  languageList: { name: string, code: string }[]
}
const defaultState: LanguageState = {
  language: 'zh',
  languageList: [
    { name: '中文', code: 'zh' },
    { name: 'English', code: 'en' }
  ]
}
export const languageReducer = (state = defaultState, action) => {
  if (action.type === 'change_language') {
    const newState = { ...state, language: action.payload }
    return newState
  } else if (action.type === 'add_language') {
    const newState = { ...state, languageList: [...state.languageList, action.payload] }
    console.log('newState', newState)
    return newState
  }
  return state;
}